package com.lhn.tankGame4;

/**
 * @author lhn
 * @date 2024-07-30 19:03
 *
 * 爆炸
 */

public class Bomb {
    private int x;
    private int y;

    //炸弹的生命周期
    private int life = 9;
    private boolean isLive;

    public Bomb(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getLife() {
        return life;
    }

    public void setLife(int life) {
        this.life = life;
    }

    public boolean isLive() {
        return isLive;
    }

    public void setLive(boolean live) {
        isLive = live;
    }

    @Override
    public String toString() {
        return "Bomb{" +
                "x=" + x +
                ", y=" + y +
                ", life=" + life +
                ", isLive=" + isLive +
                '}';
    }

    //减少生命值
    public void lifeDown() {
        if (life > 0) {
            life = life - 1;
        } else {
            isLive = false;
        }
    }
}
